package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.FormQuery;
import com.gec.zhs.entity.po.Form;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.FormService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 表单模板表 Controller
 */
@RestController("formController")
@RequestMapping("/form")
public class FormController extends ABaseController{

	@Resource
	private FormService formService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(FormQuery query){
		return getSuccessResponseVO(formService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Form bean) {
		formService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Form> listBean) {
		formService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Form> listBean) {
		formService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getFormById")
	public ResponseVO getFormById(String id) {
		return getSuccessResponseVO(formService.getFormById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateFormById")
	public ResponseVO updateFormById(Form bean,String id) {
		formService.updateFormById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteFormById")
	public ResponseVO deleteFormById(String id) {
		formService.deleteFormById(id);
		return getSuccessResponseVO(null);
	}
}